package com.siderakis.gwt.request;

import com.google.gwt.requestfactory.shared.RequestFactory.RequestDefinition;
import org.springframework.roo.addon.gwt.RooGwtMirroredFrom;
import com.siderakis.Note;
import com.google.gwt.requestfactory.shared.ServerType;

@RooGwtMirroredFrom(Note.class)
@ServerType(type = Note.class)
public enum NoteRequestServerSideOperations implements RequestDefinition {

    FIND_ALL_NOTES, FIND_NOTE, COUNT_NOTES, FIND_NOTE_ENTRIES;

    public String getDomainClassName() {
        return "com.siderakis.Note";
    }

    public String getDomainMethodName() {
        switch(this) {
            case FIND_ALL_NOTES:
                return "findAllNotes";
            case FIND_NOTE:
                return "findNote";
            case COUNT_NOTES:
                return "countNotes";
            case FIND_NOTE_ENTRIES:
                return "findNoteEntries";
            default:
                throw new IllegalStateException();
        }
    }

    public boolean isReturnTypeList() {
        switch(this) {
            case FIND_ALL_NOTES:
                return true;
            case FIND_NOTE:
                return false;
            case COUNT_NOTES:
                return false;
            case FIND_NOTE_ENTRIES:
                return true;
            default:
                throw new IllegalStateException();
        }
    }

    public Class<?> getReturnType() {
        switch(this) {
            case FIND_ALL_NOTES:
                return com.siderakis.gwt.request.NoteRecord.class;
            case FIND_NOTE:
                return com.siderakis.gwt.request.NoteRecord.class;
            case COUNT_NOTES:
                return java.lang.Long.class;
            case FIND_NOTE_ENTRIES:
                return com.siderakis.gwt.request.NoteRecord.class;
            default:
                throw new IllegalStateException();
        }
    }

    public Class<?>[] getParameterTypes() {
        switch(this) {
            case FIND_ALL_NOTES:
                return null;
            case FIND_NOTE:
                return new Class[] { java.lang.Long.class };
            case COUNT_NOTES:
                return null;
            case FIND_NOTE_ENTRIES:
                return new Class[] { int.class, int.class };
            default:
                throw new IllegalStateException();
        }
    }
}
